{% extends 'base.html' %}
{% load customer_filters %}
{% load customer_tags %}
{% block title %}学生列表{% endblock %}
{% block section %}学生列表{% endblock %}
{% block content %}
    <div style="display: flex;position:relative;">
        <form class="form-inline" style="display: flex;">
            <div class="form-group mx-sm-3 mb-2 col-sm-10">
                <input type="text" class="form-control" id="inputPassword2"
                       placeholder="请输入学生姓名、QQ号码或电话号码" name="search">
            </div>
            <button type="submit" class="btn btn-success mb-2 col-sm-3">搜索</button>
            <a class="btn btn-primary mb-2 col-sm-3" href="{% url 'students:list' %}">重置</a>
        </form>
        {% if perms.students.add_student %}
        <a href="{% url 'students:add' %}" class="btn btn-info mb-2" style="position:absolute;right:0;">添加学生</a>
        {% endif %}
    </div>
    <div class="table-responsive">
        <table id="recent-purchases-listing" class="table">
            <thead>
            <tr>
                <th>序号</th>
                <th>姓名</th>
                <th>年龄</th>
                <th>性别</th>
                <th>QQ号码</th>
                <th>电话号码</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {% for student in students  %}
            <tr>
                <td><a style="text-decoration: none;" href="{% url 'students:detail' student.id %}">{{ forloop.counter }}</a></td>
                <td>{{ student.name }}</td>
                <td>{{ student.age }}</td>
                <td {% if student.sex == 0 %}style="color:red;"{% endif %}>{{ student.sex|to_change }}</td>
                <td>{{ student.qq }}</td>
                <td>{{ student.phone }}</td>
{#                <!--<td>{{ student.c_time }}</td>-->#}
{#                <!--<td>{% current '%Y年%m月%d日 %H:%M:%S' %}</td>-->#}
{#                <!--<td>{{ format_str }}</td>-->#}
{#                <!--<td>{% current format_str %}</td>-->#}
                <td>{% current student.c_time %}</td>

                <td>
                    <a href="{% url 'students:edit' student.id %}" style="height:28px;line-height:25px;color:white;border-radius: 10px;"
                       class="btn btn-success">编辑</a>

                    <a href="{% url 'students:delete' student.id %}" style="height:28px;line-height:28px;color:white;border-radius: 10px;"
                            class="btn btn-danger">删除
                    </a>
                </td>
            </tr>
            {% endfor %}

            </tbody>
        </table>
    </div>
    <div class="btn-group" role="group" aria-label="Button group with nested dropdown">
        {#  分页部分  #}
        {% pagination_html %}
        <div class="input-group-prepend" style="margin-top: -13px;">
            <button class="btn btn-sm btn-outline-primary dropdown-toggle" type="button"
                    data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{ per_page }}条/页
            </button>
            <div class="dropdown-menu" style="">
                <a class="dropdown-item" href="{{ request.path }}?per_page=5">5条/页</a>
                <a class="dropdown-item" href="{{ request.path }}?per_page=10">10条/页</a>
                <a class="dropdown-item" href="{{ request.path }}?per_page=20">20条/页</a>
                <a class="dropdown-item" href="{{ request.path }}?per_page=100">100条/页</a>
            </div>
        </div>
    </div>
{% endblock %}


